#include<iostream>
using namespace std;
const int N = 210;
int x[N],w[N],v[N];
int f[N][N];
int main()
{
    int n,t;
    cin >> n >> t;
    for(int i = 1; i <= n; i++) cin >> x[i] >> w[i] >> v[i];
    
    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= t; j++)
            for(int k = 0; k <= x[i] && w[i] * k <= j; k++)
                f[i][j] = max(f[i][j],f[i - 1][j - k * w[i]] + k * v[i]);
    cout << f[n][t] << endl;
    return 0;
}
